<?php
/**
 * Helper for making comment box
 *
 * @subpackage Helper
 * @copyright
 * @license
 */
class cms_View_Helper_Commentbox
{
	public $view;
	private $_module;
	public function Commentbox($options = array(), $partial = 'commentbox.phtml')
	{
	    $lang = Utils_Global::getCurrentLanguage();
	    if($lang == 'en') {
	        $partial = str_replace('.phtml', '_en.phtml', $partial);
	    }
	    $comments = array();
	    $courseId = $options['id'];
	    $limit = $options['limit'];
	    if(!$limit) {
	        $limit = 10;
	    }
	    if($courseId) {
    	    $model = Cms_Model_Comment::factory();
    	    $condition = array('course_id' => $courseId, 'offset' => 0, 'limit' => $limit);
    	    $comments = $model->select($condition);
    	    $total = $model->count($condition);
	    }

	    $data->comments = $comments;
	    $data->totalItem = $total;
	    $data->page = 1;
	    $data->numRowPerPage = $limit;
	    $data->content = $this->view->partial('comment/get-comment.phtml', $data);
		return $this->view->partial($partial, $data);
	}	
	
	public function setView(Zend_View_Interface $view)
	{
		$this->view = $view;
	}
}
?>